home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Make / source / make.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-27  |  10.9 KB  |  459 lines

  1. /* Miscellaneous global declarations and portability cruft for GNU Make.
  2. Copyright (C) 1988,89,90,91,92,93,94,95,96,97 Free Software Foundation, Inc.
  3. This file is part of GNU Make.
  4.  
  5. GNU Make is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. GNU Make is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU Make; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* AIX requires this to be the first thing in the file.  */
  20. #if defined (_AIX) && !defined (__GNUC__)
  21.  #pragma alloca
  22. #endif
  23.  
  24. /* We use <config.h> instead of "config.h" so that a compilation
  25.    using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
  26.    (which it would do because make.h was found in $srcdir).  */
  27. #include <config.h>
  28. #undef    HAVE_CONFIG_H
  29. #define HAVE_CONFIG_H
  30.  
  31.  
  32. /* Use prototypes if available.  */
  33. #if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
  34. #undef  PARAMS
  35. #define PARAMS(protos)  protos
  36. #else /* Not C++ or ANSI C.  */
  37. #undef  PARAMS
  38. #define PARAMS(protos)  ()
  39. #endif /* C++ or ANSI C.  */
  40.  
  41.  
  42. #ifdef    CRAY
  43. /* This must happen before #include <signal.h> so
  44.    that the declaration therein is changed.  */
  45. #define    signal    bsdsignal
  46. #endif
  47.  
  48. #define _GNU_SOURCE
  49. #include <sys/types.h>
  50. #include <sys/stat.h>
  51. #include <signal.h>
  52. #include <stdio.h>
  53. #include <ctype.h>
  54. #ifdef HAVE_SYS_TIMEB_H
  55. /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
  56.    unless <sys/timeb.h> has been included first.  Does every system have a
  57.    <sys/timeb.h>?  If any does not, configure should check for it.  */
  58. #include <sys/timeb.h>
  59. #endif
  60. #include <time.h>
  61. #include <errno.h>
  62.  
  63. #ifndef    errno
  64. extern int errno;
  65. #endif
  66.  
  67. #ifndef    isblank
  68. #define    isblank(c)    ((c) == ' ' || (c) == '\t')
  69. #endif
  70.  
  71. #ifdef    HAVE_UNISTD_H
  72. #include <unistd.h>
  73. /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
  74.    POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself!  */
  75. #if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
  76. #define    POSIX
  77. #endif
  78. #endif
  79.  
  80. /* Some systems define _POSIX_VERSION but are not really POSIX.1.  */
  81. #if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
  82. #undef POSIX
  83. #endif
  84.  
  85. #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
  86. #define POSIX
  87. #endif
  88.  
  89. #ifdef HAVE_SYS_SIGLIST
  90. #ifndef SYS_SIGLIST_DECLARED
  91. extern char *sys_siglist[];
  92. #endif
  93. #else
  94. #include "signame.h"
  95. #endif
  96.  
  97. /* Some systems do not define NSIG in <signal.h>.  */
  98. #ifndef    NSIG
  99. #ifdef    _NSIG
  100. #define    NSIG    _NSIG
  101. #else
  102. #define    NSIG    32
  103. #endif
  104. #endif
  105.  
  106. #ifndef    RETSIGTYPE
  107. #define    RETSIGTYPE    void
  108. #endif
  109.  
  110. #ifndef    sigmask
  111. #define    sigmask(sig)    (1 << ((sig) - 1))
  112. #endif
  113.  
  114. #ifdef    HAVE_LIMITS_H
  115. #include <limits.h>
  116. #endif
  117. #ifdef    HAVE_SYS_PARAM_H
  118. #include <sys/param.h>
  119. #endif
  120.  
  121. #ifndef    PATH_MAX
  122. #ifndef    POSIX
  123. #define    PATH_MAX    MAXPATHLEN
  124. #endif    /* Not POSIX.  */
  125. #endif    /* No PATH_MAX.  */
  126. #ifndef MAXPATHLEN
  127. #define MAXPATHLEN 1024
  128. #endif    /* No MAXPATHLEN.  */
  129.  
  130. #ifdef    PATH_MAX
  131. #define    GET_PATH_MAX    PATH_MAX
  132. #define    PATH_VAR(var)    char var[PATH_MAX]
  133. #else
  134. #define    NEED_GET_PATH_MAX
  135. extern unsigned int get_path_max PARAMS ((void));
  136. #define    GET_PATH_MAX    (get_path_max ())
  137. #define    PATH_VAR(var)    char *var = (char *) alloca (GET_PATH_MAX)
  138. #endif
  139.  
  140. #ifndef CHAR_BIT
  141. #define CHAR_BIT 8
  142. #endif
  143.  
  144. /* Nonzero if the integer type T is signed.  */
  145. #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
  146.  
  147. /* The minimum and maximum values for the integer type T.
  148.    Use ~ (t) 0, not -1, for portability to 1's complement hosts.  */
  149. #define INTEGER_TYPE_MINIMUM(t) \
  150.   (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
  151. #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
  152.  
  153. #ifdef    STAT_MACROS_BROKEN
  154. #ifdef    S_ISREG
  155. #undef    S_ISREG
  156. #endif
  157. #ifdef    S_ISDIR
  158. #undef    S_ISDIR
  159. #endif
  160. #endif    /* STAT_MACROS_BROKEN.  */
  161.  
  162. #ifndef    S_ISREG
  163. #define    S_ISREG(mode)    (((mode) & S_IFMT) == S_IFREG)
  164. #endif
  165. #ifndef    S_ISDIR
  166. #define    S_ISDIR(mode)    (((mode) & S_IFMT) == S_IFDIR)
  167. #endif
  168.  
  169. #ifdef VMS
  170. #include <stdio.h>
  171. #include <types.h>
  172. #include <unixlib.h>
  173. #include <unixio.h>
  174. #include <errno.h>
  175. #include <perror.h>
  176. #endif
  177.  
  178. #if    (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) || defined(VMS))
  179. #include <stdlib.h>
  180. #include <string.h>
  181. #define    ANSI_STRING
  182. #else    /* No standard headers.  */
  183.  
  184. #ifdef HAVE_STRING_H
  185. #include <string.h>
  186. #define    ANSI_STRING
  187. #else
  188. #include <strings.h>
  189. #endif
  190. #ifdef    HAVE_MEMORY_H
  191. #include <memory.h>
  192. #endif
  193.  
  194. extern char *malloc PARAMS ((int));
  195. extern char *realloc PARAMS ((char *, int));
  196. extern void free PARAMS ((char *));
  197.  
  198. extern void abort PARAMS ((void));
  199. extern void exit PARAMS ((int));
  200.  
  201. #endif    /* Standard headers.  */
  202.  
  203. #ifdef    ANSI_STRING
  204.  
  205. #ifndef    index
  206. #define    index(s, c)    strchr((s), (c))
  207. #endif
  208. #ifndef    rindex
  209. #define    rindex(s, c)    strrchr((s), (c))
  210. #endif
  211.  
  212. #ifndef    bcmp
  213. #define bcmp(s1, s2, n)    memcmp ((s1), (s2), (n))
  214. #endif
  215. #ifndef    bzero
  216. #define bzero(s, n)    memset ((s), 0, (n))
  217. #endif
  218. #if defined(HAVE_MEMMOVE) && !defined(bcopy)
  219. #define bcopy(s, d, n)    memmove ((d), (s), (n))
  220. #endif
  221.  
  222. #else    /* Not ANSI_STRING.  */
  223.  
  224. #ifndef    bcmp
  225. extern int bcmp ();
  226. #endif
  227. #ifndef    bzero
  228. extern void bzero ();
  229. #endif
  230. #ifndef    bcopy
  231. extern void bcopy ();
  232. #endif
  233.  
  234. #endif    /* ANSI_STRING.  */
  235. #undef    ANSI_STRING
  236.  
  237. /* SCO Xenix has a buggy macro definition in <string.h>.  */
  238. #undef    strerror
  239.  
  240. #if !defined(ANSI_STRING) && !defined(__DECC)
  241. extern char *strerror PARAMS ((int errnum));
  242. #endif
  243.  
  244.  
  245. #ifdef    __GNUC__
  246. #undef    alloca
  247. #define    alloca(n)    __builtin_alloca (n)
  248. #else    /* Not GCC.  */
  249. #ifdef    HAVE_ALLOCA_H
  250. #include <alloca.h>
  251. #else    /* Not HAVE_ALLOCA_H.  */
  252. #ifndef    _AIX
  253. extern char *alloca ();
  254. #endif    /* Not AIX.  */
  255. #endif    /* HAVE_ALLOCA_H.  */
  256. #endif    /* GCC.  */
  257.  
  258. #ifndef    iAPX286
  259. #define streq(a, b) \
  260.   ((a) == (b) || \
  261.    (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
  262. #ifdef _AMIGA
  263. #define strieq(a, b) \
  264.   ((a) == (b) || \
  265.    (tolower(*(a)) == tolower(*(b)) && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
  266. #else
  267. #define strieq(a, b) \
  268.   ((a) == (b) || \
  269.    (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
  270. #endif
  271. #else
  272. /* Buggy compiler can't handle this.  */
  273. #define streq(a, b) (strcmp ((a), (b)) == 0)
  274. #define strieq(a, b) (strcmp ((a), (b)) == 0)
  275. #endif
  276.  
  277. /* Add to VAR the hashing value of C, one character in a name.  */
  278. #define    HASH(var, c) \
  279.   ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
  280. #ifdef _AMIGA /* Fold filenames on #amiga */
  281. #define HASHI(var, c) \
  282.   ((var += tolower((c))), (var = ((var) << 7) + ((var) >> 20)))
  283. #else
  284. #define HASHI(var, c) HASH(var,c)
  285. #endif
  286.  
  287. #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
  288. #define    ENUM_BITFIELD(bits)    :bits
  289. #else
  290. #define    ENUM_BITFIELD(bits)
  291. #endif
  292.  
  293. #if defined(__MSDOS__) || defined(WINDOWS32)
  294. #define PATH_SEPARATOR_CHAR ';'
  295. #else
  296. #if defined(VMS)
  297. #define PATH_SEPARATOR_CHAR ','
  298. #else
  299. #define PATH_SEPARATOR_CHAR ':'
  300. #endif
  301. #endif
  302.  
  303. #ifdef WINDOWS32
  304. #include <fcntl.h>
  305. #include <malloc.h>
  306. #define pipe(p) _pipe(p, 512, O_BINARY)
  307. #define kill(pid,sig) w32_kill(pid,sig)
  308.  
  309. extern void sync_Path_environment(void);
  310. extern int kill(int pid, int sig);
  311. extern int safe_stat(char *file, struct stat *sb);
  312. extern char *end_of_token_w32();
  313. #endif
  314.  
  315. extern void die ();
  316. extern void message ();
  317. extern void fatal ();
  318. extern void error ();
  319. extern void log_working_directory ();
  320. extern void makefile_error ();
  321. extern void makefile_fatal ();
  322. extern void pfatal_with_name ();
  323. extern void perror_with_name ();
  324. extern char *savestring ();
  325. extern char *concat ();
  326. extern char *xmalloc ();
  327. extern char *xrealloc ();
  328. extern char *find_next_token ();
  329. extern char *next_token ();
  330. extern char *end_of_token ();
  331. extern void collapse_continuations ();
  332. extern void remove_comments ();
  333. extern char *sindex ();
  334. extern char *lindex ();
  335. extern int alpha_compare ();
  336. extern void print_spaces ();
  337. extern struct dep *copy_dep_chain ();
  338. extern char *find_char_unquote ();
  339. extern char *find_percent ();
  340.  
  341. #ifndef    NO_ARCHIVES
  342. extern int ar_name ();
  343. extern void ar_parse_name ();
  344. extern int ar_touch ();
  345. extern time_t ar_member_date ();
  346. #endif
  347.  
  348. extern void dir_load ();
  349. extern int dir_file_exists_p ();
  350. extern int file_exists_p ();
  351. extern int file_impossible_p ();
  352. extern void file_impossible ();
  353. extern char *dir_name ();
  354.  
  355. extern void define_default_variables ();
  356. extern void set_default_suffixes ();
  357. extern void install_default_suffix_rules ();
  358. extern void install_default_implicit_rules ();
  359. extern void count_implicit_rule_limits ();
  360. extern void convert_to_pattern ();
  361. extern void create_pattern_rule ();
  362.  
  363. extern void build_vpath_lists ();
  364. extern void construct_vpath_list ();
  365. extern int vpath_search ();
  366. extern int gpath_search ();
  367.  
  368. extern void construct_include_path ();
  369. extern void uniquize_deps ();
  370.  
  371. extern int update_goal_chain ();
  372. extern void notice_finished_file ();
  373.  
  374. extern void user_access ();
  375. extern void make_access ();
  376. extern void child_access ();
  377.  
  378. #ifdef    HAVE_VFORK_H
  379. #include <vfork.h>
  380. #endif
  381.  
  382. /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
  383.    because such systems often declare them in header files anyway.  */
  384.  
  385. #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
  386.  
  387. extern long int atol ();
  388. #ifndef VMS
  389. extern long int lseek ();
  390. #endif
  391.  
  392. #endif    /* Not GNU C library or POSIX.  */
  393.  
  394. #ifdef    HAVE_GETCWD
  395. extern char *getcwd ();
  396. #ifdef VMS
  397. extern char *getwd PARAMS ((char *));
  398. #endif
  399. #else
  400. extern char *getwd ();
  401. #define    getcwd(buf, len)    getwd (buf)
  402. #endif
  403.  
  404. extern char **environ;
  405.  
  406. extern char *reading_filename;
  407. extern unsigned int *reading_lineno_ptr;
  408.  
  409. extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
  410. extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
  411. extern int env_overrides, no_builtin_rules_flag, print_version_flag;
  412. extern int print_directory_flag, warn_undefined_variables_flag;
  413. extern int posix_pedantic;
  414. extern int clock_skew_detected;
  415.  
  416. extern unsigned int job_slots;
  417. #ifndef NO_FLOAT
  418. extern double max_load_average;
  419. #else
  420. extern int max_load_average;
  421. #endif
  422.  
  423. extern char *program;
  424. extern char *starting_directory;
  425. extern unsigned int makelevel;
  426. extern char *version_string, *remote_description;
  427.  
  428. extern unsigned int commands_started;
  429.  
  430. extern int handling_fatal_signal;
  431.  
  432.  
  433. #define DEBUGPR(msg) \
  434.   do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
  435.                fflush (stdout); } while (0)
  436.  
  437. #ifdef VMS
  438. # ifndef EXIT_FAILURE
  439. #  define EXIT_FAILURE 3
  440. # endif
  441. # ifndef EXIT_SUCCESS
  442. #  define EXIT_SUCCESS 1
  443. # endif
  444. # ifndef EXIT_TROUBLE
  445. #  define EXIT_TROUBLE 2
  446. # endif
  447. #else
  448. # ifndef EXIT_FAILURE
  449. #  define EXIT_FAILURE 2
  450. # endif
  451. # ifndef EXIT_SUCCESS
  452. #  define EXIT_SUCCESS 0
  453. # endif
  454. # ifndef EXIT_TROUBLE
  455. #  define EXIT_TROUBLE 1
  456. # endif
  457. #endif
  458.  
  459.